package cn.bas.controller;

import cn.bas.dto.UserAddDTO;
import cn.bas.dto.UserUpdateDTO;
import cn.bas.vo.UserVo;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

@RestController
@RequestMapping("/user2")
public class UserController02 {

    @GetMapping("/list")
    public List<UserVo> list(){
        List<UserVo> list = new ArrayList<>();
        list.add(new UserVo().setId(1).setUsername("tom"));
        list.add(new UserVo().setId(2).setUsername("jack"));
        list.add(new UserVo().setId(3).setUsername("mark"));
        return  list;
    }

    @GetMapping("/get")
    public UserVo get(Integer id){
        return new UserVo().setId(1).setUsername(UUID.randomUUID().toString());
    }

    @PostMapping("add")
    public Integer add(UserAddDTO addDTO) {
        Integer returnId = UUID.randomUUID().hashCode();
        return returnId;
    }

    @PostMapping("/update")
    public Boolean update(UserUpdateDTO updateDTO) {
        Boolean success = true;
        return success;
    }

    @DeleteMapping("/delete")
    public Boolean delete(@RequestParam("id") Integer id) {
        Boolean success = false;
        return success;
    }
}
